package com.example.onion.hxchat.room.entity;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;

/**
 * @author:onion
 * @data: 2020/7/8
 */
@Entity(tableName = "Message")
public class Message {


    @PrimaryKey(autoGenerate = true)
    @ColumnInfo(name = "id", typeAffinity = ColumnInfo.INTEGER)
    public int id;

    @ColumnInfo(name = "userId", typeAffinity = ColumnInfo.TEXT)
    public String userId;//发送该信息的的人的用户ID

    @ColumnInfo(name = "content", typeAffinity = ColumnInfo.TEXT)
    public String content; //消息的内容

    @ColumnInfo(name = "toUserId", typeAffinity = ColumnInfo.TEXT)
    public String toUserId;//接收该消息的用户id

    @ColumnInfo(name = "type", typeAffinity = ColumnInfo.INTEGER)
    public int type;//消息的类型  Msg.TYPE_RECEIVED = 0 TYPE_SENT = 1

    @ColumnInfo(name = "time", typeAffinity = ColumnInfo.TEXT)
    public String time;//消息发送接收的时间




    /**
     * Room会使用这个构造器来存储数据，也就是当你从表中得到Student对象时候，Room会使用这个构造器
     */
    public Message(int id, String userId, String content, String toUserId, int type, String time) {
        this.id = id;
        this.userId = userId;
        this.content = content;
        this.toUserId = toUserId;
        this.type = type;
        this.time = time;
    }

    /**
     * 由于Room只能识别和使用一个构造器，如果希望定义多个构造器，你可以使用Ignore标签，让Room忽略这个构造器
     * 同样，@Ignore标签还可用于字段，使用@Ignore标签标记过的字段，Room不会持久化该字段的数据
     */
    @Ignore
    public Message(String userId, String content, String toUserId, int type, String time) {
        this.userId = userId;
        this.content = content;
        this.toUserId = toUserId;
        this.type = type;
        this.time = time;
    }
    @Ignore
    public Message(){

    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public void setToUserId(String toUserId) {
        this.toUserId = toUserId;
    }

    public void setType(int type) {
        this.type = type;
    }

    public void setTime(String time) {
        this.time = time;
    }


    public int getId() {
        return id;
    }

    public String getUserId() {
        return userId;
    }

    public String getContent() {
        return content;
    }

    public String getToUserId() {
        return toUserId;
    }

    public int getType() {
        return type;
    }

    public String getTime() {
        return time;
    }

}
